﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CandyBlast
{
    public static class ProjectConnector
    {

        public static string GetCandyConnectionString(string project)
        {

            using (CandyAuthSbDataContext authContext = new CandyAuthSbDataContext())
            {
                var p = authContext.Projects.SingleOrDefault(x => x.Name.ToLower() == project.Trim().ToLower());
                if (p != null)
                    return p.ConnectionString;
                else
                    return null;
            }
        }

        public static string GetCandyConnectionString(int projectId)
        {

            using (CandyAuthSbDataContext authContext = new CandyAuthSbDataContext())
            {
                var p = authContext.Projects.SingleOrDefault(x => x.Id == projectId);
                if (p != null)
                    return p.ConnectionString;
                else
                    return null;
            }
        }
    }
}
